#define _CRT_SECURE_NO_WARNINGS 1
using namespace std;
#include <iostream>

string addStrings(string num1, string num2)
{
    int end1 = num1.size() - 1;
    int end2 = num2.size() - 1;
    int next = 0;
    string ret;
    while (end1 >= 0 || end2 >= 0)
    {
        int x = end1 >= 0 ? num1[end1--] - '0' : 0;
        int y = end2 >= 0 ? num2[end2--] - '0' : 0;
        int sum = x + y + next;
        ret.push_back(sum % 10 + '0');
        next = sum / 10;
    }
    if (next > 0)
    {
        ret.push_back(next + '0');
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main()
{
    string s1 = "123";
    string s2 = "456";
    cout << addStrings(s1, s2) << endl;

    return 0;
}